package cn.chrilwe.pigpig.user.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.chrilwe.pigpig.core.model.user.Role;
import cn.chrilwe.pigpig.core.response.BaseResult;
import cn.chrilwe.pigpig.user.common.ResponseEnum;
import cn.chrilwe.pigpig.user.mapper.RoleMapper;

@Service
public class RoleService {

	@Autowired
	private RoleMapper roleMapper;
	
	public BaseResult addRole(Role role) {
		if(role != null) {
			String name = role.getName();
			Role r = roleMapper.selectRoleByName(name);
			if(r != null) {
				return new BaseResult(ResponseEnum.ROLE_EXISTS.getCode(),ResponseEnum.ROLE_EXISTS.getName());
			}
		}
		return null;
	}

}
